<template>
  <view v-if="!loadding" :data-theme="theme()" :class="theme() || ''">
    <view class="bg-white p-0-30 f30">
      <view class="recharge_money">
        <view>{{recharge_money}}</view>
        <view>账户余额(绿色金币)</view>
      </view>
      <view class="d-s-c border-b-d9">
        <text class="key-name">手机号</text>
        <input
          class="ml20 flex-1 f32 p-30-0"
          type="number"
          placeholder-class="grary9"
          v-model="phone"
          placeholder="请输入收货人手机号"
        />
      </view>
      <view class="d-s-c border-b-d9">
        <text class="key-name">金币</text>
        <input
          class="ml20 flex-1 f32 p-30-0"
          type="number"
          placeholder-class="grary9"
          v-model="point"
          placeholder="请输入金币"
        />
      </view>
      <!-- <view class="d-s-c border-b-d9">
        <text class="key-name">金币类型</text>
        <radio-group @change="radioChange" class="radioGroup">
          <label
            class="radioGroup p-30-0"
            style="margin-left: 20rpx"
            v-for="(item, index) in integralList"
            :key="item.index"
          >
            <view>
              <radio :value="item.type" :checked="index === current" />
            </view>
            <view>{{ item.name }}</view>
          </label>
        </radio-group>
      </view> -->
    </view>
    <view class="p30"
      ><view @click="submit" class="theme-btn f32 mt60 addBtn">
        保存
      </view></view
    >
  </view>
</template>

<script>
export default {
  data() {
    return {
      /*是否加载完成*/
      loadding: false,
      indicatorDots: true,
      autoplay: true,
      interval: 2000,
      duration: 500,
      integralList: [
        {
          name: "服务金币",
          type: 1,
        },
        {
          name: "绿色金币",
          type: 2,
        },
      ],
      integralType: "",
      point: "",
      phone: "",
      /*数据*/
      listData: [],
      /*默认地址id*/
      default_id: "0",
      recharge_money:"",
      address: {},
      options: {},
    };
  },
  onLoad: function (options) {
    this.options = options;
    this.recharge_money=uni.getStorageSync('recharge_money');

  },
  onShow: function () {
    // uni.showLoading({
    //   title: "加载中",
    // });
    /*获取地址列表*/
  },
  methods: {
    /*获取数据*/
    getData() {
      let self = this;
      let dataType = self.dataType;
      self._get("user.address/lists", {}, function (res) {
        self.listData = res.data.list;
        self.default_id = res.data.default_id + "";
        self.loadding = false;
        uni.hideLoading();
      });
    },
    /*提交*/
    submit(e) {
      let self = this;
      if (this.phone == "") {
        uni.showToast({
          title: "请输入手机号码",
          duration: 1000,
          icon: "none",
        });
        return;
      }
      if (this.point == "") {
        uni.showToast({
          title: "请输入金币",
          duration: 1000,
          icon: "none",
        });
        return;
      }
    //   if (this.integralType == "") {
    //     uni.showToast({
    //       title: "请选择金币类型",
    //       duration: 1000,
    //       icon: "none",
    //     });
    //     return;
    //   }
      uni.showLoading({
        title: "提交中",
      });
      self._post(
        "user.transfer/add",
        {
          phone: this.phone,
          point: this.point,
          point_type: 2,
        },
        function (res) {
          uni.hideLoading();
          if (res.code == 1) {
            self.integralType = "";
            self.point = "";
            self.phone = "";
            uni.showToast({
              title: "金币赠送成功",
            });
          }
        }
      );
    },
    radioChange(e) {
      console.log("e", e);
      this.integralType = e.detail.value;
    },
  },
};
</script>

<style lang="scss">
page {
  background-color: #ffffff;
}
.recharge_money{
  margin: 30rpx auto;
  text-align: center;
  font-size: 30rpx;
  >view:first-child{
    font-size: 44rpx;
    font-weight: 600;
    margin-bottom: 10rpx;
  }
  >view:last-child{

  }
}
.radioGroup {
  display: flex;
  align-items: center;
}
.address-list {
  border-top: 16rpx solid #f2f2f2;
  padding: 0 20rpx;
  padding-bottom: 90rpx;
}

.foot-btns {
  padding: 0;
}

.foot-btns .btn-red {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  border-radius: 0;
}

.none_add {
  padding: 314rpx 214rpx 60rpx 214rpx;
}

.no_add {
  width: 322rpx;
  height: 180rpx;
}

.no_add_add {
  width: 320rpx;
  height: 80rpx;
  border: 2rpx solid #ffb7b7;
  border-radius: 40rpx;
  text-align: center;
  line-height: 80rpx;
  font-size: 32rpx;
  font-family: PingFang SC;
  font-weight: 500;
  @include font_color("font_color");
  @include border_color("border_color");
  margin: 0 auto;
}

.add_add {
  height: 64rpx;
  line-height: 64rpx;
  font-size: 26rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #0777cd;
  padding: 0 35rpx;
  border-bottom: 1rpx solid #d9d9d9;
}

.defaul_add {
  padding: 9rpx 14rpx 10rpx 15rpx;
  @include background_color("bg-op");
  font-size: 22rpx;
  font-family: PingFang SC;
  font-weight: 500;
  color: #f6220c;
  @include font_color("font_color");
}

.add_icon_img {
  width: 30rpx;
  height: 30rpx;
}

.none_line {
  width: 1rpx;
  height: 44rpx;
  background: #d9d9d9;
}
.add_add-btn {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 20rpx);
  width: 690rpx;
  margin: 20rpx 30rpx;
  box-sizing: border-box;
  font-size: 28rpx;
  height: 80rpx;
  border-radius: 40rpx;
  display: flex;
  justify-content: center;
  align-items: center;
}
.pbenv {
  padding-bottom: calc(env(safe-area-inset-bottom) + 120rpx);
  box-sizing: border-box;
}

.address-form {
  /* border-top: 16rpx solid #f2f2f2; */
}

.address-form .key-name {
  width: 140rpx;
  font-size: 32rpx;
}

.address-form .btn-red {
  height: 88rpx;
  line-height: 88rpx;
  border-radius: 44rpx;
  box-shadow: 0 8rpx 16rpx 0 rgba(226, 35, 26, 0.6);
}

.addBtn {
  height: 80rpx;
  line-height: 80rpx;
  border-radius: 40rpx;
  text-align: center;
}
</style>
